package com.example.yyh.recorddemo.bean;

import android.content.ContentValues;
import android.database.Cursor;

import java.io.Serializable;

/**
 * Created by yaoyihang on 2018/12/1.
 * 数据库实体类
 */

public class SoundBean implements Serializable{

    //唯一标示
    private String id;

    //文件名
    private String name;

    //文件创建时间
    private String time;

    //文件大小
    private String fileSize;

    //文件路径
    private String filePath;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getFileSize() {
        return fileSize;
    }

    public void setFileSize(String fileSize) {
        this.fileSize = fileSize;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }


    /**
     * 取出数据
     *
     * @param cursor
     */
    public SoundBean(Cursor cursor) {
        name = cursor.getString(cursor.getColumnIndex(Column.NAME));
        time = cursor.getString(cursor.getColumnIndex(Column.TIME));
        filePath = cursor.getString(cursor.getColumnIndex(Column.FILEPATH));
        fileSize = cursor.getString(cursor.getColumnIndex(Column.FILESIZE));
        id = cursor.getString(cursor.getColumnIndex(Column.ID));
    }

    public SoundBean() {
    }

    /**
     * 数据库列表名
     */
    public static final class Column {
        public static final String AUTO_ID = "AUTO_ID";
        public static final String ID = "ID";
        public static final String NAME = "NAME";
        public static final String TIME = "TIME";
        public static final String FILESIZE = "FILESIZE";
        public static final String FILEPATH = "FILEPATH";
    }

    /**
     * 存储数据
     *
     * @return
     */
    public ContentValues getContentValus() {
        ContentValues values = new ContentValues();
        values.put(Column.NAME, name);
        values.put(Column.TIME, time);
        values.put(Column.FILEPATH, filePath);
        values.put(Column.FILESIZE, fileSize);
        values.put(Column.ID, id);
        return values;
    }
}
